<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div id="app">
    <div v-if="books.length>0">
    <table>
      <thead>
        <tr>
          <th></th>
          <th>书籍名称</th>
          <th>价格</th>
          <th>出版日期</th>
          <th>购买数量</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(book,index) of books">
          <th>{{book.id}}</th>
          <th>{{book.name}}</th>
          <!-- <th>{{'$'+book.price.toFixed(2)}}</th> -->
          <th>{{book.price | showPrice}}</th>
          <th>{{book.date}}</th>
          <th><button @click="plus(index)">+</button>
            &nbsp;&nbsp;{{book.count}}&nbsp;&nbsp;
            <button @click="min(index)" :disabled="book.count===1">-</button></th>
          <th><button @click="del(index)">删除</button></th>
        </tr>
      </tbody>
    </table>
    
    <span>总价：{{totalPrice | showPrice}}</span>
  </div>
  <div v-else>
    <h2>购物车为空</h2>
  </div>
  </div>
  <script src="../js/vue.js"></script>
  <script src="main.js"></script>
</body>

</html>